using System;

namespace Sedna.Core.Persistence
{
	/// <summary>
	/// this attribute is used to define the automatic generation of the NHibernate ICriteria
	/// based on the values of the <see cref="ICriteriaFilterState"/> class.
	/// The attribute shall be applied to every property that is considered to hold the filter state
	/// </summary>
	[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
	public class FilterPropertyAttribute : Attribute
	{
		/// <summary>
		/// expression for a particular field to use in the result SQL query to be applied to the field.
		/// by default for string type fields the FullLike strategy is used which means that the table values will be likened to 
		/// the field value surrounded with '%' symbols (E.g. TABLE_A.FIELD_A like '%ObjectFieldValue%')
		/// and for non string type fields Eq (equals) strategy is used (E.g. TABLE_A.FIELD_B=5)
		/// </summary>
		public FilterEquality FilterEquality = FilterEquality.Default;

		/// <summary>
		/// defines the strategy how to handle the values that are unset.
		/// the default behaviour is just skip them from a criteria
		/// </summary>
		public FilterUnsetStrategy FilterUnsetStrategy = FilterUnsetStrategy.Skip;

		/// <summary>
		/// this field is necessary to designate the which value to count as unser in case of structures
		/// such as Int32. E.g. -1 can be counted as an unset value thus it becomes 
		/// the subject of the <c>FilterUnsetStrategy</c> value
		/// </summary>
		public object UnsetValue = null;

		/// <summary>
		/// strategy to combine several criterions (each for a separate field).
		/// the default value is And, which means that the result criterion is a conjunction of 
		/// all criterias
		/// </summary>
		public FilterCriterionAppendStrategy FilterCriterionAppendStrategy = FilterCriterionAppendStrategy.And;

		/// <summary>
		/// target persistence class field name.
		/// if the value is not set (null) then the name assumed to be the same as the 
		/// name of the fileter state class property
		/// </summary>
		public string FieldName = null;
	}
}
